/*
 * Ingenic SU SDK ADC test.
 *
 * Copyright (C) 2014 Ingenic Semiconductor Co.,Ltd
 * Author: Tiger <bohu.liang@ingenic.com>
 */

#include <fcntl.h>
#include <unistd.h>
#include <semaphore.h>

#include <sys/time.h>
#include <sys/stat.h>
#include <sys/types.h>

#include <CUnit/CUnit.h>
#include <CUnit/Basic.h>
#include <CUnit/Console.h>
#include <CUnit/Automated.h>

#include <imp/imp_log.h>
#include <imp/imp_common.h>

#include <sysutils/su_adc.h>

#include <system/system.h>
#include <system/vbm.h>

#define TAG		"TEST_ADC"

static void test_adc()
{
	int ret, value;

	ret = SU_ADC_Init();
	if(ret < 0) {
		IMP_LOG_ERR(TAG, "SU_ADC_INIT() error !\n");
		CU_FAIL();
		return ;
	}

	ret = SU_ADC_EnableChn(0);
	if(ret < 0) {
		IMP_LOG_ERR(TAG, "SU_ADC_EnableChn() error !\n");
		CU_FAIL();
		return ;
	}

	ret = SU_ADC_GetChnValue(0, &value);
	if(ret < 0) {
		IMP_LOG_ERR(TAG, "SU_ADC_GetValue() error !\n");
		CU_FAIL();
		return ;
	}

	printf("value : %d\n", value);

	SU_ADC_DisableChn(0);

	SU_ADC_Exit();

	CU_PASS();

	return ;
}

CU_TestInfo ADCTest[] = {
	{"adc", test_adc},
	CU_TEST_INFO_NULL,
};
